import React, { PureComponent } from 'react';
import { Tag } from 'antd';
import styles from './index.less';
import TaobaoApproveColumn from '../TaobaoApproveColumn';
import { DISPATCH_OPERATION } from '../../constants';

export default class TaskStatusColumn extends PureComponent {
  render() {
    const { status, task } = this.props;
    // console.log(task)
    let taobaoApprove = '';
    if (task && task.taobao && task.taobao.auditStatusName) {
      taobaoApprove = (<TaobaoApproveColumn value={task.taobao}/>);
    }
    if (status === -3) {
      return '已创建';
    } else if (status === -2) {
      return (<Tag className={styles['ant-tag']} color="#C1C1C1">已上架</Tag> );
    } else if (status === -1) {
      return (<Tag className={styles['ant-tag']} color="#00b395">待完成</Tag>);
    } else if (status === 0) {
      const approveDispatchs = task && task.dispatchs ? task.dispatchs.filter(item => item.operation === DISPATCH_OPERATION.approve) : [];
      let text = '待审核';
      if (approveDispatchs.length > 1) {
        text = '复审中';
      }
      return (<Tag className={styles['ant-tag']} color="#108ee9">{text}</Tag>);
    } else if (status === 1) {
      return (<Tag className={styles['ant-tag']} color="#87d068">已通过</Tag>);
    } else if (status === 2) {
      if (taobaoApprove) return taobaoApprove;
      return (<Tag className={styles['ant-tag']} color="#f50">未通过</Tag>);
    } else if (status === 3) {
      return (<Tag className={styles['ant-tag']} color="#8A2BE2">待发布</Tag>);
    } else if (status === 4) {
      if (taobaoApprove) return taobaoApprove;
      return (<Tag className={styles['ant-tag']} color="#FFC125">已发布</Tag>);
    } else if (status === 5) {
      if (taobaoApprove) return taobaoApprove;
      return (<Tag className={styles['ant-tag']} color="#87d068">淘宝通过</Tag>);
    } else if (status === 6) {
      if (taobaoApprove) return taobaoApprove;
      return (<Tag className={styles['ant-tag']} color="#f50">淘宝不通过</Tag>);
    } else {
      return <span>{status}</span> ;
    }
  }
}
